package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.system.domain.SysMealStatistics;
import com.ruoyi.system.service.ISysMealStatisticsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 报餐统计Controller
 *
 * @author jijinwu
 * @date 2024-07-19
 */
@Api(tags = "报餐统计")
@RestController
@RequestMapping("/system/statistics")
public class SysMealStatisticsController extends BaseController
{
    @Autowired
    private ISysMealStatisticsService sysMealStatisticsService;

    /**
     * 查询报餐统计列表
     */
    @ApiOperation(value = "查询报餐统计列表")
    @PreAuthorize("@ss.hasPermi('system:statistics:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysMealStatistics sysMealStatistics)
    {
        startPage();
        List<SysMealStatistics> list = sysMealStatisticsService.selectSysMealStatisticsList(sysMealStatistics);
        return getDataTable(list);
    }

    /**
     * 导出报餐统计列表
     */
    @ApiOperation(value = "导出报餐统计列表")
    @PreAuthorize("@ss.hasPermi('system:statistics:export')")
    @Log(title = "报餐统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysMealStatistics sysMealStatistics)
    {
        List<SysMealStatistics> list = sysMealStatisticsService.selectSysMealStatisticsList(sysMealStatistics);
        ExcelUtil<SysMealStatistics> util = new ExcelUtil<SysMealStatistics>(SysMealStatistics.class);
        util.exportExcel(response, list, "报餐统计数据");
    }

    /**
     * 获取报餐统计详细信息
     */
    @ApiOperation(value = "获取报餐统计详细信息")
    @PreAuthorize("@ss.hasPermi('system:statistics:query')")
    @GetMapping("/getInfo")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysMealStatisticsService.selectSysMealStatisticsById(id));
    }

    /**
     * 新增报餐统计
     */
    @ApiOperation(value = "新增报餐统计")
    @PreAuthorize("@ss.hasPermi('system:statistics:add')")
    @Log(title = "报餐统计", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody SysMealStatistics sysMealStatistics)
    {
        return toAjax(sysMealStatisticsService.insertSysMealStatistics(sysMealStatistics));
    }

    /**
     * 修改报餐统计
     */
    @ApiOperation(value = "修改报餐统计")
    @PreAuthorize("@ss.hasPermi('system:statistics:edit')")
    @Log(title = "报餐统计", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody SysMealStatistics sysMealStatistics)
    {
        return toAjax(sysMealStatisticsService.updateSysMealStatistics(sysMealStatistics));
    }

    /**
     * 删除报餐统计
     */
    @ApiOperation(value = "删除报餐统计")
    @ApiImplicitParam(name = "id", value = "报餐统计D",paramType = "query", dataType = "Long")
    @PreAuthorize("@ss.hasPermi('system:statistics:remove')")
    @Log(title = "报餐统计", businessType = BusinessType.DELETE)
    @DeleteMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysMealStatisticsService.deleteSysMealStatisticsByIds(ids));
    }
}
